/* eslint-disable vue/html-quotes */
<template>
  <div class="content-wrapper">
    <!-- <div class="content-header"></div>
       <div class="title">
      <div>试卷管理</div>
    </div>
     <el-divider></el-divider> -->
    <div class="content-container">
      <el-form :inline="true" :model="listQuery" class="filter-container">
        <el-form-item label="分类">
          <el-select v-model="listQuery.category" clearable size="mini">
            <el-option
              v-for="category in categoryDict"
              :key="category.dictId"
              :label="category.dictValue"
              :value="category.dictId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="类型">
          <el-select v-model="listQuery.type" clearable size="mini">
            <el-option
              v-for="item in typeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="listQuery.status" clearable size="mini">
            <el-option
              v-for="item in [
                { value: 0, label: '停用' },
                { value: 1, label: '启用' }
              ]"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="名称">
          <el-input
            v-model="listQuery.examinationPaperName"
            type="text"
            size="mini"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            class="filter-item"
            size="small"
            round
            type="primary"
            icon="el-icon-search"
            @click="getDataList"
          >
            搜索
          </el-button>
          <el-button
            class="filter-item"
            size="small"
            round
            icon="el-icon-download"
            @click="handleFilter"
          >
            导出
          </el-button>
          <el-button
            class="filter-item"
            size="small"
            round
            icon="el-icon-plus"
            @click="openFixedPaperDialog"
          >
            新增固定试卷
          </el-button>
          <el-button
            class="filter-item"
            size="small"
            round
            icon="el-icon-plus"
            @click="openRandomPaperDialog"
          >
            新增随机试卷
          </el-button>
          <el-button
            class="filter-item"
            size="small"
            type="danger"
            plain
            round
            icon="el-icon-delete"
            @click="multipleDelete"
          >
            批量删除
          </el-button>
        </el-form-item>
      </el-form>
      <el-table
        ref="examinationTable"
        v-loading="listLoading"
        :data="dataList"
        highlight-current-row
        @selection-change="changeFun"
      >
        <el-table-column type="selection" width="55" />
        <el-table-column
          label="类型"
          prop="type"
          width="150px"
          align="center"
          :formatter="
            (row, column, cellValue, index) => {
              return cellValue == 0 ? '固定试卷' : '随机试卷'
            }
          "
        />
        <el-table-column
          label="名称"
          prop="examinationPaperName"
          min-width="200px"
        />
        <el-table-column label="总分" prop="totalScore" width="100px" />
        <el-table-column label="通过分数" prop="passScore" width="100px" />
        <el-table-column label="考试时长" prop="duration" width="100px" />
        <el-table-column label="状态" prop="status" width="100px">
          <template slot-scope="{ row }">
            <el-tag v-if="row.status == 1" type="success">启用</el-tag>
            <el-tag v-else type="danger">停用</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="创建时间" prop="createTime" width="160px">
          <template slot-scope="{ row }">
            <span v-if="row.createTime">{{
              $moment(row.createTime).format('YYYY-MM-DD')
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          align="center"
          width="150px"
          fixed="right"
        >
          <template slot-scope="{ row, $index }">
            <el-dropdown trigger="click" class="filter-item">
              <el-button type="text" class="el-icon-more" />
              <el-dropdown-menu slot="dropdown" class="user-dropdown">
                <el-dropdown-item @click.native="toExaminationView(row)"
                  >预览</el-dropdown-item
                >
                <!-- <el-dropdown-item>二维码</el-dropdown-item> -->
                <el-dropdown-item
                  v-if="row.type == 0"
                  @click.native="editExamination(row)"
                  >编辑</el-dropdown-item
                >
                <el-dropdown-item
                  v-if="row.type == 1"
                  @click.native="openGenerateRuleDialog(row)"
                  >生成规则</el-dropdown-item
                >
                <el-dropdown-item
                  v-if="row.type == 1"
                  @click.native="randomPaper(row)"
                  >随机生题</el-dropdown-item
                >
                <el-dropdown-item
                  v-if="row.status == 1"
                  @click.native="switchs(row, 0)"
                  >停用</el-dropdown-item
                >
                <el-dropdown-item v-else @click.native="switchs(row, 1)"
                  >启用</el-dropdown-item
                >
                <el-dropdown-item
                  divided
                  @click.native="deleteExaminationPaper(row)"
                  >删除</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page-number.sync="listQuery.pageNumber"
        :page-size.sync="listQuery.pageSize"
        @pagination="getDataList"
      />
    </div>

    <el-dialog
      title="新增固定试卷"
      :visible.sync="createFixedPaperDialog"
      width="50%"
      @close="closeCreateFixedPaperDialog"
    >
      <el-form
        ref="fixedPaperForm"
        :rules="rules.fixedPaperForm"
        :model="fixedPaperForm"
        inline-message
        label-width="80px"
      >
        <el-form-item label="试卷分类" prop="category">
          <el-select
            v-model="fixedPaperForm.category"
            clearable
            placeholder="请选择试卷分类"
          >
            <el-option
              v-for="category in categoryDict"
              :key="category.dictId"
              :label="category.dictValue"
              :value="category.dictId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="试卷名称" prop="examinationPaperName">
          <el-input
            v-model="fixedPaperForm.examinationPaperName"
            maxlength="100"
            placeholder="请输入试卷名称"
          />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="createFixedPaperDialog = false">取 消</el-button>
        <el-button type="primary" @click="createFixedPaper">提 交</el-button>
      </span>
    </el-dialog>

    <el-dialog
      title="新增随机试卷"
      :visible.sync="createRandomPaperDialog"
      width="50%"
      @close="closeCreateRandomPaperDialog"
    >
      <el-form
        ref="randomPaperForm"
        :rules="rules.randomPaperForm"
        :model="randomPaperForm"
        inline-message
        label-width="80px"
      >
        <el-form-item label="试卷分类" label-width="120px" prop="category">
          <el-select
            v-model="randomPaperForm.category"
            clearable
            placeholder="请选择试卷分类"
          >
            <el-option
              v-for="category in categoryDict"
              :key="category.dictId"
              :label="category.dictValue"
              :value="category.dictId"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="试卷名称"
          label-width="120px"
          prop="examinationPaperName"
        >
          <el-input
            v-model="randomPaperForm.examinationPaperName"
            maxlength="100"
            placeholder="请输入试卷名称"
          />
        </el-form-item>
        <el-form-item label="试卷总分" label-width="120px" prop="totalScore">
          <el-input
            v-model="randomPaperForm.totalScore"
            placeholder="请输入试卷总分"
          />
        </el-form-item>
        <el-form-item label="通过分数" label-width="120px" prop="passScore">
          <el-input
            v-model="randomPaperForm.passScore"
            placeholder="请输入试卷通过分数"
          />
        </el-form-item>
        <el-form-item label="考试时长" label-width="120px" prop="duration">
          <el-input
            v-model="randomPaperForm.duration"
            placeholder="请输入试卷考试时长(分钟)"
          />
        </el-form-item>
        <el-form-item
          label="允许次数"
          label-width="120px"
          prop="numberOfExamsAllowed"
        >
          <el-input
            v-model="randomPaperForm.numberOfExamsAllowed"
            placeholder="请输入试卷允许考试次数"
          />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="createRandomPaperDialog = false">取 消</el-button>
        <el-button type="primary" @click="createRandomPaper">提 交</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="dialogExaminationPaperView" width="70%">
      <ViewFixedPaper :paper-data="paperData" />
    </el-dialog>
    <el-dialog
      title="设置生成规则"
      :visible.sync="dialogGenerateRule"
      width="40%"
      @close="closeGenerateRuleDialog"
    >
      <el-form
        ref="generateRuleForm"
        :model="generateRuleForm"
        :rules="rules.generateRuleForm"
        label-width="80px"
      >
        <el-row>
          <el-col :span="8">
            <el-form-item label="题库分类" prop="questionCategory">
              <el-select
                v-model="generateRuleForm.questionCategory"
                clearable
                placeholder="请选择题库分类"
              >
                <el-option
                  v-for="item in categoryOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="试题类型" prop="questionType">
              <el-select
                v-model="generateRuleForm.questionType"
                clearable
                placeholder="请选择试题类型"
              >
                <el-option
                  v-for="item in questionTypeOptions"
                  :key="item.key"
                  :label="item.value"
                  :value="item.key"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="难度" prop="difficulty">
              <el-select
                v-model="generateRuleForm.difficulty"
                clearable
                placeholder="选择难度等级"
              >
                <el-option
                  v-for="item in difficultyOptions"
                  :key="item.key"
                  :label="item.value"
                  :value="item.key"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="分数" prop="score">
              <el-input
                v-model="generateRuleForm.score"
                placeholder="请输入分数"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="可用题数">
              <el-input
                v-model="topicNumber"
                disabled
                placeholder="请输入题数"
              />
            </el-form-item>
          </el-col>
          <el-col :span="4" />

          <el-col :span="8">
            <el-form-item label="题数">
              <el-input
                v-model="generateRuleForm.count"
                placeholder="请输入题数"
                :disabled="!propFlag"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item>
          <el-button
            round
            plain
            type="primary"
            :disabled="!generateRuleForm.count"
            @click="setGenerateRule"
            >添加</el-button
          >
        </el-form-item>
      </el-form>
      <el-table :data="generateRuleDataList" style="width: 100%">
        <el-table-column
          prop="questionCategory"
          label="题库分类"
          width="180"
          :formatter="
            (row, column, cellValue, index) => {
              return categoryOptions.find((item) => {
                if (item.value == cellValue) {
                  return item
                }
              }).label
            }
          "
        />
        <el-table-column
          prop="questionType"
          label="试题类型"
          width="180"
          :formatter="
            (row, column, cellValue, index) => {
              return questionTypeOptions.find((item) => {
                if (item.key == cellValue) {
                  return item
                }
              }).value
            }
          "
        />
        <el-table-column
          prop="difficulty"
          label="难度"
          width="180"
          :formatter="
            (row, column, cellValue, index) => {
              return difficultyOptions.find((item) => {
                if (item.key == cellValue) {
                  return item
                }
              }).value
            }
          "
        />
        <el-table-column prop="count" label="题数" width="180" />
        <el-table-column prop="score" label="分数" />
        <el-table-column fixed="right" label="操作" width="80">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="deleteRow(scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div class="my-span-box">
        <el-button
          round
          :disabled="disabledViewFlag"
          @click="toExaminationView(generateRuleForm)"
          >预览</el-button
        >
        <!-- :disabled="disabledNewFlag" -->
        <el-button round @click="randomPaper(generateRuleForm)"
          >随机生题</el-button
        >
        <!-- <el-button round type="primary" @click="setGenerateRule"
          >生成规则</el-button
        > -->
      </div>
      <!-- <span class="dialog-footer" style="float: right">
        <el-button @click="dialogGenerateRule = false">取 消</el-button>
        <el-button type="primary" @click="setGenerateRule">添加</el-button>
      </span> -->
    </el-dialog>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import ViewFixedPaper from '@/views/train/examination_list_paper/paperView/viewFixedPaper'
import {
  saveFixedPaper,
  page,
  preview,
  refineFixedPaper,
  deleteExaminationPaper,
  saveRandom,
  generateRandomPaper,
  deleteMultiple,
  examinationPaperUpdate
} from '@/api/ts/paper'
import { listDictItem } from '@/api/base/dict'
import { save, list, deleteRule } from '@/api/ts/rule'
import { listDictTreeItem, countExaminationQuestion } from '@/api/ts/question'
import { getExaminationOptions } from '@/api/ts/train.js'

export default {
  components: {
    Pagination,
    ViewFixedPaper
  },
  data() {
    return {
      typeOptions: [
        { label: '固定试卷', value: 0 },
        { label: '随机试卷', value: 1 }
      ],
      dataList: [],
      total: 0,
      categoryOptions: [],
      listQuery: {
        pageNumber: 1,
        pageIndex: 0,
        pageSize: 10,
        category: null,
        type: null,
        content: null
      },
      listLoading: false,
      createFixedPaperDialog: false,
      createRandomPaperDialog: false,
      fixedPaperForm: {
        // 固定试卷
        category: null,
        examinationPaperName: null
      },
      randomPaperForm: {
        // 随机试卷
        category: null,
        examinationPaperName: null,
        totalScore: null,
        passScore: null,
        duration: null,
        numberOfExamsAllowed: null
      },
      generateRuleForm: {
        // 随机试卷规则
        examinationPaperId: null,
        questionCategory: null,
        questionType: null,
        difficulty: null,
        count: null,
        score: null
      },
      rules: {
        fixedPaperForm: {
          category: [
            { required: true, message: '不能为空', trigger: 'change' }
          ],
          examinationPaperName: [
            { required: true, message: '不能为空', trigger: 'change' }
          ]
        },
        randomPaperForm: {
          category: [
            { required: true, message: '不能为空', trigger: 'change' }
          ],
          examinationPaperName: [
            { required: true, message: '不能为空', trigger: 'change' }
          ],
          totalScore: [
            { required: true, message: '不能为空', trigger: 'change' },
            {
              pattern: /^[1-9][0-9]{0,1}$/,
              message: '请输1-99之间的正整数',
              trigger: 'change'
            }
          ],
          passScore: [
            { required: true, message: '不能为空', trigger: 'change' },
            {
              pattern: /^[1-9][0-9]{0,1}$/,
              message: '请输1-99之间的正整数',
              trigger: 'change'
            }
          ],
          duration: [
            { required: true, message: '不能为空', trigger: 'change' },
            {
              pattern: /^(?!0)(?:[0-9]{1,3}|1000)$/,
              message: '请输1-1000之间的正整数',
              trigger: 'change'
            }
          ],
          numberOfExamsAllowed: [
            { required: true, message: '不能为空', trigger: 'change' },
            {
              pattern: /^[1-9][0]{0,1}$/,
              message: '请输1-10之间的正整数',
              trigger: 'change'
            }
          ]
        },
        generateRuleForm: {
          examinationPaperId: [
            { required: true, message: '不能为空', trigger: 'change' }
          ],
          questionCategory: [
            { required: true, message: '不能为空', trigger: 'change' }
          ],
          questionType: [
            { required: true, message: '不能为空', trigger: 'change' }
          ],
          difficulty: [
            { required: true, message: '不能为空', trigger: 'change' }
          ],
          count: [
            { required: true, message: '不能为空', trigger: 'change' },
            {
              pattern: /^[1-9][0]{0,1}$/,
              message: '请输1-' + this.topicNumber + '之间的正整数',
              trigger: 'change'
            }
          ],
          score: [
            { required: true, message: '不能为空', trigger: 'change' },
            {
              pattern: /^[1-9][0]{0,1}$/,
              message: '请输1-10之间的正整数',
              trigger: 'change'
            }
          ]
        }
      },
      paperData: null,
      dialogExaminationPaperView: false,
      dialogGenerateRule: false, // 生成规则对话框
      categoryDict: null,
      multipleSelection: null, // 复选框值存储
      questionTypeOptions: [],
      difficultyOptions: [],
      generateRuleDataList: null,
      generateRuleDataListLength: null,
      disabledViewFlag: false,
      disabledNewFlag: false,
      newFlag: 0,
      viewFlag: 0,
      propFlag: false,
      topicNumber: null
    }
  },
  watch: {
    generateRuleDataList(data) {
      // this.generateRuleDataList = res.data
      if (data.length === this.generateRuleDataListLength) {
        this.disabledViewFlag = false
        this.disabledNewFlag = true
      } else {
        this.disabledViewFlag = true
        this.disabledNewFlag = false
      }
      if (this.newFlag > 0) {
        this.disabledViewFlag = true
        this.disabledNewFlag = false
        if (data.length === 0) {
          this.disabledNewFlag = true
        }
      }
    },
    viewFlag(data) {
      if (data > 0) {
        this.disabledViewFlag = false
        this.disabledNewFlag = true
      }
    },
    generateRuleForm: {
      handler(newVal) {
        if (this.$refs['generateRuleForm']) {
          this.$refs['generateRuleForm'].validate((valid) => {
            if (valid) {
              countExaminationQuestion(newVal).then((res) => {
                this.topicNumber = res.data
                this.propFlag = true
                // this.generateRuleForm.count=''
              })
            }
          })
        }
      },
      deep: true,
      immediate: true
    }
  },
  mounted() {
    this.getDataList()
    this.getDictItem()
    this.listDictTreeItem()
  },
  methods: {
    getGenerateRuleData(row) {},
    closeGenerateRuleDialog() {
      this.$refs.generateRuleForm.resetFields()
    },
    setGenerateRule() {
      // this.generateRuleDataList.push(this.generateRuleForm)
      this.$refs.generateRuleForm.validate((valid) => {
        if (valid) {
          save(this.generateRuleForm).then((res) => {
            this.openGenerateRuleDialog(this.generateRuleForm)
            this.$message.success('添加规则成功')
            this.newFlag = this.newFlag + 1
            // this.disabledNewFlag = false
            // this.disabledViewFlag = true

            // this.dialogGenerateRule = false
          })
        }
      })
    },
    async listDictTreeItem() {
      const dataList = await listDictTreeItem({
        dictGroupCode: 'examination_question_category',
        parentDictId: 0
      })
      this.categoryOptions = dataList.data
    },
    openGenerateRuleDialog(row) {
      this.dialogGenerateRule = true
      this.generateRuleForm.examinationPaperId = row.examinationPaperId
      this.generateRuleForm.totalScore = row.totalScore
      this.generateRuleForm.passScore = row.passScore

      // 请求获取规则列表
      list({ examinationPaperId: row.examinationPaperId }).then((res) => {
        this.generateRuleDataList = res.data
        this.generateRuleDataListLength = res.data.length
      })
    },
    changeFun(val) {
      // 复选框状态改变
      this.multipleSelection = val
    },
    multipleDelete() {
      // 删除多个试卷
      if (!this.multipleSelection || this.multipleSelection.length === 0) {
        this.$message.info('未选择')
        return
      }
      var deleteDatas = this.multipleSelection.map((item) =>
        parseInt(item.examinationPaperId)
      )

      this.$confirm('此操作将删除选中试卷, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          deleteMultiple(deleteDatas).then((res) => {
            this.$message.success('删除成功')
            this.getDataList()
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    async randomPaper(row) {
      let totalScore = 0
      this.generateRuleDataList.forEach((e) => {
        let a = 0
        a = e.score * e.count
        totalScore = totalScore + a
      })
      console.log(row, '6666')
      if (row.totalScore !== totalScore) {
        this.$prompt(
          '该规则的总分与试卷的总分不相符' +
            '(' +
            totalScore +
            '/' +
            row.totalScore +
            ')' +
            '，是否替换，并重新设置通过分数',
          '提示',
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            inputValidator: (value) => {
              if (value === null) {
                return false
              }
              return totalScore > value
            },
            inputErrorMessage: '不能大于总分与空'
          }
        )
          .then(async({ value }) => {
            await examinationPaperUpdate({
              examinationPaperId: row.examinationPaperId,
              passScore: value,
              totalScore: totalScore
            })
            // 生成随机试题
            await generateRandomPaper({
              examinationPaperId: row.examinationPaperId
            }).then((res) => {
              this.$message.success('随机试题生成成功')
              this.viewFlag = this.viewFlag + 1
            })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '取消输入'
            })
          })
      }
    },
    getDictItem() {
      // 获取试卷分类字典数据
      listDictItem({ dictGroupCode: 'examination_paper_category' }).then(
        (res) => {
          this.categoryDict = res.data
        }
      )
    },
    deleteExaminationPaper(row) {
      this.$confirm('此操作将删除该试卷, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          deleteExaminationPaper({
            examinationPaperId: row.examinationPaperId
          }).then((res) => {
            this.getDataList()
            this.$message.success('删除成功')
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    switchs(row, val) {
      var data = {
        examinationPaperId: row.examinationPaperId,
        status: val
      }
      this.$confirm('此操作将更改试卷状态, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          refineFixedPaper(data).then((res) => {
            this.getDataList()
            this.$message.success(val === 0 ? '停用成功' : '启用成功')
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消更改'
          })
        })
    },
    toExaminationView(row) {
      var data = {
        examinationPaperId: row.examinationPaperId,
        type: 0
      }
      preview(data).then((res) => {
        this.paperData = res.data
        this.dialogExaminationPaperView = true
      })
    },
    editExamination(row) {
      if (row.type === 0) {
        this.$router.push(
          '/train/examination_fixed_paper/' + row.examinationPaperId
        )
      } else {
        this.$message.info('页面未实现')
      }
    },
    closeCreateFixedPaperDialog() {
      this.$refs.fixedPaperForm.resetFields()
    },
    closeCreateRandomPaperDialog() {
      this.$refs.randomPaperForm.resetFields()
    },
    createRandomPaper() {
      // 新增随机试卷
      this.$refs.randomPaperForm.validate((validate) => {
        if (validate) {
          saveRandom(this.randomPaperForm).then((res) => {
            this.$message.success('保存成功')
            this.createRandomPaperDialog = false
            this.getDataList()
          })
        }
      })
    },
    createFixedPaper() {
      // 新增固定试卷
      this.$refs.fixedPaperForm.validate((validate) => {
        if (validate) {
          saveFixedPaper(this.fixedPaperForm).then((res) => {
            this.$message.success('保存成功')
            this.createFixedPaperDialog = false
            this.getDataList()
          })
        }
      })
    },
    openFixedPaperDialog() {
      // 打开新增固定试卷
      this.createFixedPaperDialog = true
    },
    openRandomPaperDialog() {
      // 打开新增随机试卷
      this.createRandomPaperDialog = true
    },
    handleFilter() {},
    async getDataList() {
      await getExaminationOptions().then((res) => {
        this.questionTypeOptions = res.data.examinationQuestionType
        this.difficultyOptions = res.data.examinationQuestionDifficulty
      })
      this.listQuery.pageIndex = this.listQuery.pageNumber - 1
      await page(this.listQuery).then((res) => {
        this.dataList = res.data.rows
        this.total = res.data.total
      })
    },
    deleteRow(row) {
      const data = this.generateRuleDataList || []

      this.$confirm('此操作将删除改规则, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          data.forEach((e, index) => {
            if (e.score === row.score) {
              data.splice(index, 1)
              deleteRule({
                examinationPaperRuleId: row.examinationPaperRuleId
              }).then((res) => {})
            }
          })
          this.newFlag + 1
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    }
  }
}
</script>

<style lang="scss" scope>
// .el-table{
//   max-height: 50vh;
// }
.my-span-box {
  margin-top: 10px;
  height: 20px;
  font-size: 20px;
  width: 100%;
  text-align: right;
}
</style>
